<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>字体放大</h1>
    <button id="big">放大</button>
    <button id="small">缩小</button>
    <button id="restore">还原</button>
    <div id="content">
        <p>javascript很强大</p>
    </div>
</body>
</html>
<script>
    var content = document.getElementById('content');
    var big = document.getElementById('big');
    var small = document.getElementById('small');
    var restore = document.getElementById('restore');
    var size = 16;
    big.onclick = function(){
        size += 2;
        content.style.fontSize = size + 'px';
    }
    small.onclick = function(){
        size -= 2;
        content.style.fontSize = size + 'px';
    }
    restore.onclick = function(){
        size = 16;
        content.style.fontSize = size + 'px';
    }  
</script>